package org.lds.scheduled.job.admin.starter.rebalance;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.lds.scheduled.job.common.util.ScheduledUtil;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class AutoReBalanceStarter implements ApplicationRunner {
    private final RebalancedService rebalancedService;

    /**
     * 10分钟执行一次重平衡
     * @param args
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {
        ScheduledUtil.scheduled(600, () -> execute());
    }

    private void execute() {
        rebalancedService.rebalanced();
    }

}
